design – Inject an Operation ID across multiple application layers

I am playing with my simple personal project – a simple REST API application and I am currently struggling with a kind of design problem.

The problem:

How to insert an operation ID (request ID, an identifier of each operation) into each “layer”?

Context:

Let’s say I have a UserRepository trait (interface) with 2 implementations (say, InMemory and Database), which is used by multiple services (say, CreateUserService, UpdateUserService). All these services are then used by a facade, let’s say the UserFacade. This facade is called by the CLI tool or the Users REST handler.
What I would like to be able to do is to create a unique Operation ID for each “operation” (request or a CLI call). This ID would be used for logging across the whole application, I would like to be able to access it in the repositories, services and facade. Later I would like to access the logs and trace how the request was processed by each of the layers.

Possible solutions that come to my mind are:

  • Pass this operation ID to each method as an additional parameter. I
    consider this ugly since the interface would be polluted by the extra parameter, unrelated to the business logic.

  • Create a whole structure of facades and services using the operation ID (the ID will be provided to each instance via the constructor for each request or CLI
    action). I like this approach but I think this would be performance/memory heavy because it would need to create a lot of objects for each processed request.

  • Some “global state” (thread-local…) storing the operation ID?

I am trying to not specify any concrete language since I consider this a general problem, more related to the design than the used language or technology.

8 – Inject the page title as a CSS class

I use this preprocessing function to insert the page title as a CSS class:

function cw8_preprocess_html(&$variables) {

  $request = Drupal::request();
  $route_match = Drupal::routeMatch();
  $title = Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());

  $css_title = DrupalComponentUtilityHtml::cleanCssIdentifier($title);
  $variables('attributes')('class')() = strtolower($css_title);
}

I found this function here: How do I insert the title of the page as a class in the page title block?

However, the following errors appear on some pages (e.g. user profile pages):

Notice: Array to string conversion in DrupalComponentUtilityHtml::cleanCssIdentifier() (line 124 of core/lib/Drupal/Component/Utility/Html.php).

Warning: strtolower() expects parameter 1 to be string, array given in cw8_preprocess_html() (line 15 of themes/custom/cw8/cw8.theme).

I suspect this is because there is no page title on these pages. So my question is, how can I change the function so that it doesn't work if the page title doesn't exist?

C # – Inject Decorators – Software Engineering Stack Exchange

I recently learned about the decoration pattern to dynamically expand the existing behavior. So I have this code:

IMyInterface b = new A();
if(someCondition)
    b = new B(b);
if(secondCondition)
    b = new C(b);

and so on where all classes A, B and C to implement IMyInterface and B and C are the decorators. The final request for a method can therefore be processed by up to three instances in the example above.

Now, however, I want to add a decorator to my code because I have a plugin mechanism that allows me to separate product code from project specific code. That's why I don't know anything B and C. So I want a way to return a decorated instance of my user interface so that I can chain multiple plugins and therefore multiple decorators:

IMyInterface b = new A();
/* collect the decorators from all plugins and chain them to get the final instance */

Does anyone have a good idea how to create the instances?

Trump didn't tell us to inject Lysol, he told us to inject hydrogen peroxide? ?

Only Trump used the word "disinfectant". "First aid antiseptic" is on the label of a hydrogen peroxide bottle. If he had suggested an antiseptic, we would know, but he didn't. By the way, even the bottle of hydrogen peroxide says "for external use only", but a good attempt to defend everything Trump says is a very difficult task. No reason, he'll change his mind tomorrow anyway.

Was Trump sarcastic when he said they should inject disinfectants as CoVid19 treatment?

Please show me where he said "inject bleach / lysol / alcohol / etc into the bloodstream".

> Have you ever heard of … uh … DOGS and CATS?

> How about "FLEAS"?

> Well then; If so, how about "FRONTLINE"?

> See, Frontline turns her blood into POIISONNN !!!!!!!!!

Dreadful!

It turns our best friends' blood into GIFT !!!!

Flea bites puppy / kitten and flea dies !!!!

You people would break your neck and try to please your own lonely genitals with your lips.

onepage checkout – Inject third party javascript on a onecheckout page in Magento 1

First, let me say that I don't know Magento 1 at all. This is a job I do for someone, so you have to endure me and apologize for the apparent lack of knowledge.

I am creating a custom checkout built into a third party that is PCI / DSS compliant. The reason for this is that the current merchant is not PCI / DSS compatible and therefore cannot handle credit card data properly.

I use the standard purchase process from Magento 1. I understand that it is referred to as a one-page checkout. I want to inject some javascript after the order is placed. The Javascript is custom and comes from a URL on a third-party server.

My goal is this:

  • User comes to checkout and to Clicking the "Send order" button will insert Javascript into the page

  • The Javascript shows the cash register of a third party

  • After the user has paid, they will be redirected to the "Thanks" page in Magento

Sounds simple enough.

So far I've added an observer controller_action_postdispatch_checkout_onepage_saveOrder. My understanding of this observer is that it is called after the order has been saved in Mangeto.

Note: this is not all of the code. However, the observer works perfectly.


    
        
            singleton
            XXXXX_Model_Observer
            output_tco_redirect
        
    

Within this function I have the following code:

public function output_tco_redirect (Varien_Object $ Observer)
{
$ js = & # 39;

& # 39 ;;
/ ** @var Mage_Core_Model_Layout $ layout * /
$ layout = Mage :: getSingleton (& # 39; core / layout & # 39;);
/ ** @var Mage_Core_Block_Text $ block * /
$ block = $ layout-> createBlock (& ​​# 39; Mage_Core_Block_Text & # 39 ;, & # 39; tco_js & # 39;);
$ block-> setText ($ js);
/ ** @var Mage_Page_Block_Html_Head $ head * /
$ head = $ layout-> getBlock (& ​​# 39; head & # 39;);
// block header is wrong here
$ head-> append ($ block);

return $ this;
}}

I admit I have no idea if this is the right way to go or if it works at all to be with him.

Currently the problem is that the $head Block is always wrong. I assumed that a head Block will always exist, regardless of the page. I was obviously wrong.

I'm not against using another method to achieve what I'm trying to do. Unfortunately I don't know any other at the moment.

Java – Inject beans from the CDI while testing with Arquillian Chameleon

I cannot inject @Inject from CDI. The field movimentador it is always zero.

I think that's because of beans.xml, but how do I create beans.xml with maven-build-deploy because I don't use an annotated method with @Deployment

I follow this guide: https://dzone.com/articles/arquillian-chameleon-simplifying-your-arquillian-t-1

I tried to use JAVA SPI for deployment as shown here: https://github.com/arquillian/arquillian-core/blob/master/docs/deployment-archives.adoc#deployment-archives-using-java-spi
but I just can't get it to work as expected, nothing happens.

@RunWith(ArquillianChameleon.class)
@ChameleonTarget("wildfly:8.1.0.Final:managed")
@MavenBuild
public class MovimentacaoTest
{

    @Inject
    private Movimentador movimentador;

    @Test
    public void deveMovimentarCorretamente()
    {
        movimentador.movimentaPara(BtpFiltro.builder().build());
        assertThat(movimentador, notNullValue());
    }
}

Batch tracking of the error that occurs.

java.lang.NullPointerException
    at br.com.teste.arq.movimentacao.MovimentacaoTest.deveMovimentarCorretamente(MovimentacaoTest.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.jboss.arquillian.junit.Arquillian$8$1.invoke(Arquillian.java:370)
    at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:130)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:136)
    at org.jboss.arquillian.junit.Arquillian$8.evaluate(Arquillian.java:363)
    at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:245)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:422)
    at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
    at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:259)
    at org.jboss.arquillian.junit.Arquillian$7$1.invoke(Arquillian.java:315)
    at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.execute(ClientBeforeAfterLifecycleEventExecuter.java:99)
    at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.on(ClientBeforeAfterLifecycleEventExecuter.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createBeforeContext(ContainerEventController.java:124)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:130)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.fireCustomLifecycle(EventTestRunnerAdaptor.java:159)
    at org.jboss.arquillian.junit.Arquillian$7.evaluate(Arquillian.java:311)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:204)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:422)
    at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:218)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:166)
    at org.arquillian.container.chameleon.runner.ArquillianChameleon.run(ArquillianChameleon.java:47)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Index inject API error

I'm not sure if this is a GSA or Index Inject error. However, I have a project running in an instance of GSA and it sent all of my checked links to Index Inject as I stated. That is a good thing.

The bad thing is that it has 4800 links per over and over again until it has used all of the 150K link contingent that I have over there.